package great.app.luck.easybatteryrecommend;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;

public class RecommendActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mBatteryRecommendConfig = new EasyBatteryRecommendConfig(this);
		mBatteryRecommendConfig.changeNeedRecommendState();
		doRating(this, mBatteryRecommendConfig.getRecommendPakcageName());
	}

	EasyBatteryRecommendConfig mBatteryRecommendConfig;

	private void doRating(Context context, String packageName) {
		final Uri marketUri = Uri.parse("market://details?id=" + packageName);
		final Intent intent = new Intent(Intent.ACTION_VIEW, marketUri);
		intent.addCategory(Intent.CATEGORY_BROWSABLE);
		try {
			context.startActivity(intent);
		} catch (Exception e) {
			Toast.makeText(context, "No Market Client", Toast.LENGTH_SHORT)
					.show();
		}

	}
}
